{include file="common/header"}

    <body>

        <div class="layui-fluid">
            <div class="layui-row layui-col-space15">
                <div class="layui-col-md12">
                    <div class="layui-card">
                        <div class="layui-card-body ">
                            <form class="layui-form layui-col-space5">

                                <div class="layui-inline layui-show-xs-block">

                                    <input type="text" name="params[like][value]" lay-verify="title" autocomplete="off" placeholder="请输入关键词" class="layui-input layui-btn-sm" value="{$keywords.like.value|default=''}">
                                    <input name="params[like][fields]" value="admin_username" type="hidden">
                                </div>

                                <div class="layui-inline layui-show-xs-block">
                                    <button class="layui-btn"  lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
                                </div>
                            </form>
                        </div>
                        <div class="layui-card-header">
                            <button class="layui-btn layui-btn-danger" onclick="stopAll()"><i class="layui-icon"></i>批量停用/启用</button>
                            <button class="layui-btn" onclick="xadmin.open('添加用户','add',600,400)"><i class="layui-icon"></i>添加</button>
                            <button class="layui-btn layui-btn-normal" onclick="outputExcel('{:getOutputUri()}')"><i class="layui-icon">&#xe601;</i> 导出到excel</button>
                        </div>
                        <div class="layui-card-body layui-table-body layui-table-main">
                            <table class="layui-table layui-form">
                                <thead>
                                  <tr>
                                    <th>
                                      <input type="checkbox" lay-filter="checkall" name="" lay-skin="primary">
                                    </th>
                                    <th>ID</th>
                                    <th>昵称</th>
                                    <th>用户名</th>
                                    <th>所属组</th>
                                    <th>创建日期</th>
                                    <th>状态</th>
                                    <th>操作</th></tr>
                                </thead>
                                <tbody>
                                {volist name="$list" id="vo"}
                                  <tr>
                                    <td>
                                      <input type="checkbox" name="id" value="{$vo.admin_id}"   lay-skin="primary">
                                    </td>
                                      <td>{$vo.admin_id|default=""}</td>
                                   <td>{$vo.admin_nickname|default=""}</td>
                                    <td>{$vo.admin_username|default=""}</td>
                                    <td>{$vo.group_name|default=""}</td>
                                    <td>{$vo.created_at|default=""}</td>
                                    <td class="td-status">
                                        {if condition="$vo.admin_bs eq 1"}
                                            <span class="layui-btn layui-btn-normal layui-btn-mini">已启用</span>
                                        {else/}
                                            <span class="layui-btn layui-btn-normal layui-btn-danger">已停用</span>
                                        {/if}
                                    </td>
                                    <td class="td-manage">
                                      <a onclick="xadmin.open('修改密码','/admin/auth.admin/edit_pwd?id={$vo.admin_id}',500,400)" title="修改密码" href="javascript:;">
                                        <i class="layui-icon">&#xe631;</i>
                                          修改密码
                                      </a>

                                        {if condition="$vo.admin_bs eq 1"}
                                          <a title="停用" onclick="member_stop(this,'{$vo.admin_id}')" href="javascript:;">
                                            <i class="layui-icon">&#x1006;</i>
                                              停用
                                          </a>
                                        {else/}
                                        <a title="启用" onclick="member_stop(this,'{$vo.admin_id}')" href="javascript:;">
                                            <i class="layui-icon">&#xe605;</i>
                                            启用
                                        </a>
                                        {/if}
                                    </td>
                                  </tr>
                                  {/volist}

                                </tbody>
                            </table>
                        </div>
                        <div class="layui-card-body ">
                            {:$page}
                        </div>
                    </div>
                </div>
            </div>
        </div> 
    </body>
<script>

    function stopAll(argument){
        var ids = [];
        // 获取选中的id
        $('tbody input').each(function(index, el) {
            if($(this).prop('checked')){
                ids.push($(this).val())
            }
        });
        layer.confirm('确认要停用/启用吗？'+ids.toString(),function(index){
            //捉到所有被选中的，发异步进行删除
            ajaxStop(ids);
        });
    }


    function member_stop(obj,id){
        layer.confirm('确认要停用/启用该用户吗？',function(index){
            ajaxStop(id);
        });
    }

    function ajaxStop(id) {
        $.ajax({
            url:"member_stop",
            data:{id:id},
            type:"POST",
            beforeSend:function(){
                layer.load();
            },
            success:function(data){
                console.log(data);
                layer.closeAll();
                if(data.code == 200){
                    //success

                    layer.msg("修改成功",{
                        icon:1,
                        time: 1000 //2秒关闭（如果不配置，默认是3秒）
                    },function(){
                        window.location.reload();
                    });
                }else{
                    //fail
                    layer.msg('修改失败', {icon: 2});

                }
            }
        })
    }

</script>
</html>